/*
 * @Description: 你的代码我的心
 * @Author: GGB
 * @Date: 2021-12-22 14:10:13
 * @LastEditors: GGB
 * @LastEditTime: 2021-12-30 18:06:15
 */
import {
  GoodsPageParms,
  GoodsListGetResultModel,
  UpdateState,
  UpdateStockParam,
  GoodsParams
} from './model/goodsModel';
import { defHttp } from '/@/utils/http/axios';

import {
  BasicResult
} from '../model/baseModel';



enum Api {
  GoodsList = '/substore/goods/list',
  GoodsListByIds = '/substore/goods/listByIds',
  GoodsDetail = '/substore/goods/detail',
  AddGoods = '/substore/goods/add',
  EditGoods = '/substore/goods/edit',
  DeleteGoods = '/substore/goods/delete',
  GoodsState = '/substore/goods/state',
  SaveSku = '/substore/goods/saveSku'
}
/**
 * 获取商品列表
 */
export const getGoodsList = (params: GoodsPageParms) =>
  defHttp.get<GoodsListGetResultModel>({ url: Api.GoodsList, params });

/**
 * 更新商品状态
 * @param params 
 * @returns 
 */
export const updateGoodState = (params: UpdateState) =>
  defHttp.post<BasicResult>({ url: Api.GoodsState, params });

/**
* 获取商品详情
* @param params 
* @returns 
*/
export const getGoodDetail = (params: GoodsParams) =>
  defHttp.get<BasicResult>({ url: Api.GoodsDetail, params });


/**
 * 更新商品状态
 * @param params 
 * @returns 
 */
export const updateGoodsStock = (params: UpdateStockParam) =>
  defHttp.post<BasicResult>({ url: Api.SaveSku, params });